package cn.com.code.design;

import cn.com.code.design.cuisine.ICuisine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhengpei
 * @date 2021/10/24
 */
public class XiaoEr {

  private Logger logger = LoggerFactory.getLogger(XiaoEr.class);

  private List<ICuisine> cuisineList = new ArrayList<ICuisine>();

  public void order(ICuisine cuisine) {
    cuisineList.add(cuisine);
  }

  public synchronized void placeOrder() {
    for (ICuisine cuisine : cuisineList) {
      cuisine.cook();
    }
    cuisineList.clear();
  }

}
